<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
    <script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
</head>
<body>

<form id="playersForm" name="playersForm" method="post" action="add">
    <!--div的class 为error是验证错误，ok是验证成功-->
    <div>
        <label for="pname">球员姓名：</label>
        <input type="text" name="pname" id="pname" value="">
    </div>
    <div>
        <label for="birthday">出生时间：</label>
        <input type="text" name="birthday" id="birthday" value="">(yyyy-MM-dd)
    </div>
    <div>
        <label for="height">球员身高：</label>
        <input type="text" name="height" id="height" value="">(单位:cm)
    </div>
    <div>
        <label for="weight">球员体重：</label>
        <input type="text" id="weight" name="weight">(单位:kg)
    </div>
    <div>
        球员位置：
        <input type="radio" value="控球后卫" name="position" checked> 控球后卫
        <input type="radio" value="得分后卫" name="position"> 得分后卫
        <input type="radio" value="小前锋" name="position"> 小前锋
        <input type="radio" value="大前锋" name="position"> 大前锋
        <input type="radio" value="中锋" name="position"> 中锋

    </div>
    <div>
        <label>所属球队：</label>
        <select name="cid">
            <option value="请选择" disabled selected>--请选择--</option>
            <c:forEach var="clubs" items="${clubsList}">
                <option value="${clubs.cid}">${clubs.cname}</option>
            </c:forEach>
        </select>
    </div>


    <div class="supplierAddBtn">
        相关操作：
        <input type="submit" name="add" id="add" value="新增">
        <input type="button" id="back" name="back" value="返回" onclick="history.back()">
    </div>
</form>


<script>
    $(function () {
        $('form').submit(function () {
            if ($('#pname').val() === '') {
                alert("姓名不能为空")
                return false
            }

            if ($('#birthday').val() === '') {
                alert("出生日期不能为空")
                return false
            }
            if ($('#height').val() === '') {
                alert("身高不能为空")
                return false
            }
            if ($('#weight').val() === '') {
                alert("体重不能为空")
                return false
            }
            if ($('#position').val() === '') {
                alert("位置不能为空")
                return false
            }


            var patt = /^\d{4}-\d{2}-\d{2}$/;

            if(!patt.test($("input[name='birthday']").val())) {
                alert("日期格式错误");
                return false;
            }


        })
    })






</script>

</body>
</html>
